package com.oa.ylms.apps.actions.leave;

import java.util.List;

import com.oa.ylms.apps.actions.BasicAction;
import com.oa.ylms.apps.business.leave.ILeaveCheckService;
import com.oa.ylms.apps.entity.archives.StaffInfoValue;
import com.oa.ylms.apps.entity.leave.LeaveInfoValue;

@SuppressWarnings("serial")
public class LeaveCheckAction extends BasicAction {
	private ILeaveCheckService leaveCheckService;
	private List<LeaveInfoValue> leaveInfoList;
	private String staffName;
	private Integer status;
	private Integer leaveId;
	private String comments;

	public String add() {
		return "add";
	}

	public String query() {
		try {
			
			staffInfo = (StaffInfoValue) session.get("login_staffInfo");
			if ( staffInfo.getArchiveInfo().getPostInfo().getPostCategory().getCategoryId()==1){
			totalpage = leaveCheckService.countTpagesByCheckList(staffInfo,
					staffName, rows);
			count = leaveCheckService.getTotalNumber();
			if (count % rows == 0 && totalpage + 1 == currpage) {
				currpage = currpage - 1;
				totalpage = currpage;
			}
			leaveInfoList = leaveCheckService.queryCheckList(staffInfo,
					staffName, rows, currpage);
			}
			
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return "show";
	}

	public String check() {
		try {
			staffInfo = (StaffInfoValue) session.get("login_staffInfo");
			if (status == 1) {
				leaveCheckService.checkPassed(staffInfo, leaveId, comments);
			}
			if (status == 0) {
				leaveCheckService.checkFailed(staffInfo, leaveId, comments);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		return "check";
	}

	public ILeaveCheckService getLeaveCheckService() {
		return leaveCheckService;
	}

	public void setLeaveCheckService(ILeaveCheckService leaveCheckService) {
		this.leaveCheckService = leaveCheckService;
	}

	public List<LeaveInfoValue> getLeaveInfoList() {
		return leaveInfoList;
	}

	public void setLeaveInfoList(List<LeaveInfoValue> leaveInfoList) {
		this.leaveInfoList = leaveInfoList;
	}

	public String getStaffName() {
		return staffName;
	}

	public void setStaffName(String staffName) {
		this.staffName = staffName;
	}

	public Integer getStatus() {
		return status;
	}

	public void setStatus(Integer status) {
		this.status = status;
	}

	public Integer getLeaveId() {
		return leaveId;
	}

	public void setLeaveId(Integer leaveId) {
		this.leaveId = leaveId;
	}

	public String getComments() {
		return comments;
	}

	public void setComments(String comments) {
		this.comments = comments;
	}

}
